﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LibraryB
{
    /// <summary>
    /// Workaround for "Could not load type" problem:
    /// base class for ControlC.
    /// The class contains all public proberties
    /// </summary>
    public class ControlCBase : System.Web.UI.UserControl
    {
        public string test
        {
            get;
            set;
        }
    }

    public partial class ControlC : ControlCBase
    {   
        protected void Page_Load(object sender, EventArgs e)
        {
            // create new control from the same library. Use Activator.CreateInstance() instead of LoadControl 
            fourthCell.Controls.Add((Control)Activator.CreateInstance(Type.GetType("LibraryB.ControlB")));
            //It also possible to use ControlsLoader here
            //fourthCell.Controls.Add(LibraryA.Utils.ControlsLoader.LoadControl<ControlB>());            
            // create new control from other library. It is necessary to use regular constructor here
            thirdCell.Controls.Add(new LibraryA.ControlA());           
        }
    }
}